<template>
  <div>
    <div class="search" v-show="flag">
      <template>
        <div style="width: 100%">
          <el-form>
            <el-row>
              <el-col :span="6">
                <div class="contain">
                  商品名：<el-input
                    clearable
                    v-model="input"
                    style="width: 198px"
                    placeholder="请输入商品名"
                  ></el-input>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="contain">
                  审核状态：<el-select
                    clearable
                    v-model="value"
                    placeholder="请选择 审核状态"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
              <el-col :span="6" style="text-align: right">
                <el-button type="primary" @click="search">
                  <i class="el-icon-search"></i>
                  <span>搜 索</span>
                </el-button>
                <el-button @click="qingkong">
                  <i class="el-icon-delete"></i>
                  <span>清 空</span>
                </el-button>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </template>
    </div>
    <div class="content">
      <div class="menu" style="margin-top: 20px">
        <!-- <div class="left">
          <template>
            <el-form>
              <el-button
                type="primary"
                class="but"
                @click="addOrUpdateHandle()"
              >
                <i class="el-icon-plus"></i>
                <span>新增</span>
              </el-button>
            </el-form>
          </template>
        </div> -->
        <div class="right">
          <el-button class="el" @click="wu">
            <i class="el-icon-refresh"></i>
          </el-button>
          <el-button class="el" @click="down">
            <i class="el-icon-search"></i>
          </el-button>
        </div>
      </div>
      <div class="table">
        <el-table
          :data="tableData"
          stripe
          border
          style="width: 100%"
          :header-cell-style="{
            fontSize: '12px',
            backgroundColor: '#fafafa',
            color: '#333',
          }"
        >
          <el-table-column align="center" label="序号" width="49">
            <template slot-scope="scope">
              <span>{{ scope.row.serNum }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="商品名" width="96">
            <template slot-scope="scope">
              <span>{{ scope.row.title }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="用户昵称" width="92">
            <template slot-scope="scope">
              <el-tag size="mini" v-show="scope.row.status == 0" type="danger"
                >禁用</el-tag
              >
              <el-tag size="mini" v-show="scope.row.status == 1">正常</el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" label="记录时间" width="200">
            <template>
              <!-- <el-tag></el-tag> -->
            </template>
          </el-table-column>
          <el-table-column align="center" label="回复时间" width="200">
            <template slot-scope="scope">
              <span>{{ scope.row.seq }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="评价得分" width="92">
          </el-table-column>
          <el-table-column align="center" label="是否匿名" width="93">
          </el-table-column>
          <el-table-column align="center" label="审核状态" width="93">
          </el-table-column>
          <el-table-column align="center" label="操作" width="">
            <template slot-scope="scope">
              <el-button
                type="primary"
                @click="() => update(scope.$index, scope.row)"
              >
                <i class="el-icon-edit"></i>
                <span>修改</span>
              </el-button>
              <el-button type="danger" @click="del(scope.$index, scope.row)">
                <i class="el-icon-delete"></i>
                <span>删除</span>
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import { template } from "lodash";

export default {
  data() {
    return {
      flag: true,
      input: "",
      value: "",
      options: [
        {
          value: 0,
          label: "待审核",
        },
        {
          value: 1,
          label: "审核通过",
        },
        {
          value: 2,
          label: "审核未通过",
        },
      ],
      tableData: [],
    };
  },
  created() {
    this.$nextTick(() => {
      this.getData();
    });
  },
  methods: {
    getData() {
      this.$http
        .get("http://admin.yami.byesame.com/apis/prod/prodComm/page", {
          params: {
            current: 1,
            size: 20,
          },
        })
        .then((res) => {
          console.log(res);
          if (res.code == "00000") {
            this.tableData = res.data.records;
            for (let i = 0; i < this.tableData.length; i++) {
              this.$set(this.tableData, "serNum", i + 1);
            }
            console.log(this.tableData);
          }
        });
    },
    search() {},
    qingkong() {
      this.input = "";
      this.value = "";
    },
    wu() {
      this.getData();
    },
    down() {
      if (this.flag == true) {
        this.flag = false;
      } else {
        this.flag = true;
      }
    },
  },
};
</script>

<style scoped>
.el {
  padding: 12px;
  border-radius: 50%;
}

.inp {
  width: 100%;
  /* display: flex; */
}

.contain {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
}

.el-col {
  margin-right: 10px;
}

.menu {
  display: flex;
  justify-content: end;
  margin-bottom: 10px;
}
</style>
